﻿<cfscript>
/** 
* DataBase Frameworks - Sequence
* 
* @hint "DataBase Frameworks - Sequence - ClassroomType" 
*/ 

component 
	displayname="public.service.db.senate.sequence.ClassroomType" 
	output=false 
	accessors=true 
	{

	/**
	* @hint "初始化对象"
	*/
	public function init() output=false {
		return this;
	}
	
	/**
	* @hint "自定义主键规则"
	*/
	public string function getID() output=false {
		
		var nextID = "Z" & numberFormat(1, "0_");
		var sql= "	SELECT
						ct.cr_type
					FROM
						t_classroom_type ct
					WHERE
						ct.cr_type LIKE :condition 
					ORDER BY
						ct.cr_type DESC";
		
		queryObj = new Query(datasource = application.dnsMaster, maxRows = 1);
		queryObj.addParam(name = "condition", value = "Z" & "__", cfsqltype = "cf_sql_char");
		rs_check = queryObj.execute( sql = sql ).getResult();
		
		/* 
			主键生成规则 CHAR(3)
			
			B + 2位流水号
		*/
		if (rs_check.recordCount) {
			/* 创建一个追加id */
			nextID = "Z" & numberFormat((right(rs_check.cr_type, 2) + 1), "0_");
		}
		
		return nextID;
	}

}

</cfscript>